/**
 * 
 */

var index=angular.module('index',['ngRoute']);
var menuController=function($http,$scope){
    $http.get('menu/getUserMenu').then(function(data){
        $scope.menus=eval(data.data);
    });
};
index.directive('menuLeft',function(){
	var menuObject={
			templateUrl:'template/menu.html',
			replace:true,
            controller:menuController,
            restrict :'EA'
	};
	return menuObject;
});
/*index.config(['$routeProvider' ,function($routeProvider){
/*index.config(['$routeProvider', function($routeProvider) {
    $routeProvider.
    $routeProvider.
        when('/use.route',{
        when('/items/computers', {
            controller:'userCtrl',
            templateUrl:'user'
    })
    }]
);*/

index.config(['$routeProvider','$locationProvider', function($routeProvider,$locationProvider) {
    $routeProvider
        .when('/items/computers', {
            templateUrl: 'user',
            controller : "userCtrl",
        })
        .when('/user',{
            templateUrl: 'user',
            controller : "userCtrl",
        }).otherwise({redirectTo:'items/computers'});
    $locationProvider.hashPrefix('');
}]);

//自定义过滤器
index.filter('menuLimit',function () {
    var menuLimitFilter=function (input) {
        var index=input.indexOf('/');
        if(index==0){
            return input.substring(1,input.length);
        }
        return input;
    }
    return menuLimitFilter;
});

index.controller('userCtrl',function($scope){
    debugger;
});

index.run(function($rootScope){
    $rootScope.$on('$routeChangeStart', routeChangeStart);


        function routeChangeStart(event,next,current) {
            debugger
           // $log.log('routeChangeStart');
            //$log.log(arguments);
        }

});